import type { Meta, StoryObj } from "@storybook/react";
import React from "react";
import CustomerCredit from "./index";
import { faker } from "@faker-js/faker";

const meta = {
  title: "样式原子组件/客户授信额度-CustomerCredit",
  component: CustomerCredit,
  tags: ["autodocs"],
  argTypes: {},
  decorators: [
    (Story) => (
      <div
        style={{ backgroundColor: "#06112B", width: "500px", height: "400px" }}
      >
        <Story />
      </div>
    ),
  ],
} satisfies Meta<typeof CustomerCredit>;

export default meta;
type Story = StoryObj<typeof meta>;

export const basic: Story = {
  args: {
    containerId: "basicDemoId",
    unitName: "万",
    dataSource: faker.helpers
      .multiple(
        () => ({
          name: faker.animal.dog() + faker.animal.dog() + faker.animal.dog(),
          amount: faker.number.int({
            min: 1098,
            max: 5200,
          }),
          percent: faker.number.int({
            min: 0,
            max: 100,
          }),
        }),
        {
          count: 12,
        }
      )
      .sort((a, b) => a.amount - b.amount),
  },
};

export const duration: Story = {
  args: {
    containerId: "durationDemoId",
    unitName: "万",
    duration: 500,
    dataSource: faker.helpers
      .multiple(
        () => ({
          name: faker.animal.dog() + faker.animal.dog() + faker.animal.dog(),
          amount: faker.number.int({
            min: 1098,
            max: 5200,
          }),
          percent: faker.number.int({
            min: 0,
            max: 100,
          }),
        }),
        {
          count: 12,
        }
      )
      .sort((a, b) => a.amount - b.amount),
  },
};
